using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace MonoCash.ObjectModel
{
    class Transaction : ObjectModel
    {
        public Transaction()
            : base()
        {

        }
        public Transaction(object objectId) 
            : base(objectId)
        {

        }



        private DateTime date = DateTime.Today;
        public DateTime Date
        {
            get { return date; }
            set { date = value; SyncToBackend(); }
        }

        private string payee;
        public string Payee
        {
            get { return payee; }
            set { payee = value; SyncToBackend(); }
        }

        private string memo;
        public string Memo
        {
            get { return memo; }
            set { memo = value; SyncToBackend(); }
        }

        private DateTime entryDate = DateTime.Now;
        public DateTime EntryDate
        {
            get { return entryDate; }
            set { entryDate = value; SyncToBackend(); }
        }


        public Decimal Amount
        {
            get
            {
                Object amount = Program.AppSettings.Data.TransactionDetails.Compute("Sum(Amount)", "TransactionID=" + ID.ToString());
                if (amount.GetType().Name == "DBNull")
                {
                    return 0;
                }
                return Convert.ToDecimal(amount);
            }
        }







    }
}
